package it.text;

import java.util.Random;

public class text06 {
    public static void main(String[] args) {
        char[] ch = getComment();

        String check=getCheck(ch);

        System.out.print("六位数验证码:"+check);



    }

    private static String getCheck(char[] ch) {
        String yanzhengma="";
        Random r=new Random();
        for (int i = 0; i <5; i++) {
            int randIndex=r.nextInt(ch.length);
            yanzhengma+= ch[randIndex];
        }
        return yanzhengma;
    }

    private static char[] getComment() {
        char[] ch=new char[26+26+10];
        int index=0;
        for (char c='a'; c <= 'z'; c++) {
            ch[index] = c;
            index++;
        }
        for (char c = 'A'; c <= 'Z'; c++) {
                    ch[index] = c;
                    index++;
        }
        for (char c = '0'; c <= '9'; c++) {
            ch[index] = c;
            index++;
        }
        return ch;
        //        for (int n = 0; n < ch.length; n++) {
//            System.out.print(ch[n]);
//        }
    }
}
